package cn.flying.cloud.base.mail.configuration;

import javax.annotation.PostConstruct;

import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.mail.javamail.JavaMailSender;

import cn.flying.cloud.base.mail.service.MailSenderService;

/**
 * 邮件配置
 *
 * @author: admin
 * @date: 2024年05月29日 09:13
 * @version: 1.0
 */
@Configuration
public class EmailAutoConfiguration {

    @PostConstruct
    private void init() {
        // 解决邮件附件名称太长会自动截取，导致附件变成.bin格式问题
        System.setProperty("mail.mime.splitlongparameters", "false");
    }

    /**
     * @return
     */
    @Bean
    @ConditionalOnBean({JavaMailSender.class})
    public MailSenderService mailSenderService() {
        return new MailSenderService();
    }
}